// 获取历史信息
var mongoose = require('mongoose');

var model = require('../../model');
var history = model.history;
var list = model.list;

exports.getHistory = function getHistory(req, cb) {
    let query = req.query || {};
    let ktype,
        code,
        sort,
        record,
        page = query.page || 1,
        order = query.order || '-date', // 默认日期逆序
        skipNum;

    console.log(query);

    ktype = query.ktype || 'day';
    if (!query.code) {
        return cb({ msg: 'need code!' });
    }
    else {
        code = query.code;
    }

    let q = history.find({ code }, '-_id');

    let count = 

    // if (query.record) {
    //     q.limit(Number(query.record));
    //     if (query.page) {
    //         q.skip(Number(query.record * (query.page - 1)));
    //     }
    // }

    if (query.order) {
        q.sort(query.order);
    }

    q.exec((err, rel) => {
        if (err) return console.log(err) && cb(err);
        return cb(null, rel);
    });
}









